
import 'package:flutter/material.dart';
import 'package:jubobao/profile/addressBook/JuBoDepermentModel.dart';
import 'package:jubobao/profile/addressBook/JuBpEmployeeModel.dart';
import 'package:jubobao/services/JuBoHttpRequest.dart';
import 'package:lpinyin/lpinyin.dart';

class JuBoAddressBookServices {
  static Future<List<DepList>> depermentRequest() async{
    final result = await JuBoHttpRequest.request('atapi/GetDepList/?DepId=&Userid=676');
    JuBoDepermentModel model = JuBoDepermentModel.fromJson(result);
    return model.reObj.depList;
  }

  static Future<List<ReList>> employeeList() async{
    final result = await JuBoHttpRequest.request('atapi/GetEmployeeList/?Type=1&Userid=676');
    JuBoEmployeeModel model = JuBoEmployeeModel.fromJson(result);

    for(int i = 0; i < model.reList.length; i++){

      String pinyin = PinyinHelper.getPinyinE(model.reList[i].linkMan);
      String tag = pinyin.substring(0,1).toUpperCase();
      model.reList[i].linkmanPinyin = pinyin;
      if(RegExp("A-Z").hasMatch(tag)){
         model.reList[i].tagIndex = tag;
      }else{
        model.reList[i].tagIndex = "#";
      }

    }

    return model.reList;
  }

}



